﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Temp_20190707_AForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Panel panel = RandomControl();
            dockPanel1.DoDock(panel, DockAlignment.Left, DockTabGroupState.Expand);
        }


        private void button1_Click(object sender, EventArgs e)
        {
            button2_Click(sender, e);
            //dockPanel1.ShowDLPanel(null);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //dockPanel1.HideDLPanel();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            Panel panel = RandomControl();
            dockPanel1.DoDock(panel, DockAlignment.Left, DockTabGroupState.Float);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            this.dockPanel1.ResetLayout();
        }
        private void button5_Click(object sender, EventArgs e)
        {
            Panel panel左上0 = RandomControl();
            Panel panel左上1 = RandomControl();
            Panel panel左下0 = RandomControl();
            Panel panel左下1 = RandomControl();
            Panel panel左下2 = RandomControl();
            Panel panel右0 = RandomControl();
            Panel panel下0 = RandomControl();
            Panel panel下1 = RandomControl();

            Panel panel文档上0 = RandomControl();
            Panel panel文档上1 = RandomControl();
            Panel panel文档上2 = RandomControl();
            Panel panel文档上3 = RandomControl();

            Panel panel文档下0 = RandomControl();
            Panel panel文档下1 = RandomControl();
            Panel panel文档下2 = RandomControl();

            DockTabGroup group左上 = dockPanel1.DoDock(panel左上0, DockAlignment.Left);
            group左上.DoDock(panel左上1, DockAlignment.Center);

            DockTabGroup group左下 = group左上.DoDock(panel左下0, DockAlignment.Bottom);
            group左下.DoDock(panel左下1, DockAlignment.Center);
            group左下.DoDock(panel左下2, DockAlignment.Center);

            DockTabGroup group右 = dockPanel1.DoDock(panel右0, DockAlignment.Right);

            DockTabGroup group下 = dockPanel1.DoDock(panel下0, DockAlignment.Bottom);
            group下.DoDock(panel下1, DockAlignment.Center);


            DockTabGroup group文档上 = dockPanel1.DoDock(panel文档上0, DockAlignment.Center, DockTabGroupState.Expand);
            group文档上.DoDock(panel文档上1, DockAlignment.Center);
            group文档上.DoDock(panel文档上2, DockAlignment.Center);
            group文档上.DoDock(panel文档上3, DockAlignment.Center);

            DockTabGroup group文档下 = group文档上.DoDock(panel文档下0, DockAlignment.Bottom);
            group文档下.DoDock(panel文档下1, DockAlignment.Center);
            group文档下.DoDock(panel文档下2, DockAlignment.Center);
        }


        public static Panel RandomControl()
        {
            Panel panel = new Panel();
            TextBox box = new TextBox();
            box.Parent = panel;
            panel.BackColor = RandomColor();
            return panel;
        }
        public static Color RandomColor()
        {
            return Color.FromArgb(new Random(Guid.NewGuid().GetHashCode()).Next(0, 256), new Random(Guid.NewGuid().GetHashCode()).Next(0, 256), new Random(Guid.NewGuid().GetHashCode()).Next(0, 256));
        }



    }
}
